<?php
namespace Common\Controller;
use Think\Controller;
class ConfigController extends Controller{

    /**
     *  获取指定key的配置项
     * @param  $key
     * @return 配置项结果集
     */
    public function getOneConfig($key){
        if (S($key)!==false){
            return S($key);
        }
       $config= M('Config')->where(array('key'=>$key))->find();
       $item[$config['key']]=$config['value'];
       S($key,$item,300);
        return $item;
    }
    /**
     * 获取配置数组
     * @param array $key
     * @return 配置数组
     */
    public function getMoreConfig($key){
        if (S('config')!=false){
            return S('config');
        }
        if (!empty($key)){
            $map['key']=array('in',$key);
            $config=M('Config')->where($map)->select();
        }else {
            $config=M('Config')->select();
        }
        foreach ($config as $k=>$v){
            $item[$v['key']]=$v['value'];
        }
        
        S('config',$item,120);
        return $item;
    }
}